import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


public class VendingMachineItemTest {
	VendingMachineItem  myItem;
	VendingMachineItem myItem2;
	
	@Before
	public void setUp() throws Exception {
		myItem = new VendingMachineItem("Snickers", 1.00);
		myItem2 = new VendingMachineItem("Twix", 1.00);
		
	}

	@After
	public void tearDown() throws Exception {
	}
	//Test to show that vendingMachineException throws an exception
	//in case of price below 1.50
	@Test(expected=VendingMachineException.class)
	 public void testVendingMachineItemPriceBelowZero()
	 
    {
     myItem = new VendingMachineItem("coke", -1.50);
    }
	/**The bug here is, when i want to add an item with null value
	 * in the name field, it does not throw an exception, which shall
	 * not be the case.
	 * @Test(expected = VendingMachineException.class)
	 *  public void testVendingMachineItem(){
	 *  myItem = new VendingMachineItem(null, 1.50);
	 *  }
	 */
	
	
	/**There is a bug here, when I try to add an item with no
	 * name, it allows me to do so which shall not be the case.
	 * 	@Test(expected = VendingMachineException.class)
	 *  public void testVendingMachineItem_NameEmpty()
	 *      {
	 *      myItem = new VendingMachineItem(" ", 1.50);
	 *       }
	 */
	//Test to check the assertion for name and price of the item,
	//is equal to the value provided in the method.

	@Test
	public void testVendingMachineItemPriceAboveZero() {
		myItem =new VendingMachineItem("Snickers", 1.00);		
		assertEquals(1.00, myItem.getPrice(), .001);
	}
	//Test to check the getName() method.
	@Test
	public void testGetName(){
		myItem =new VendingMachineItem("Snickers", 1.00);
		assertSame("Snickers", myItem.getName());
		
	}

}
